// 安全关怀模块API服务
const SafetyCareAPI = {
  /**
   * 提交老人报平安打卡
   * @param {Object} data - 打卡数据
   * @param {string} data.elderlyId - 老人唯一标识
   * @param {string} checkInTime - 打卡时间戳
   * @returns {Promise}
   */
  submitCheckIn: function(data) {
    return new Promise((resolve, reject) => {
      // 模拟API调用
      setTimeout(() => {
        resolve({
          success: true,
          message: '打卡成功',
          data: {
            checkInId: 'check_' + Date.now(),
            checkInTime: new Date().toISOString()
          }
        });
      }, 500);
    });
  },

  /**
   * 获取老人打卡记录
   * @param {string} elderlyId - 老人唯一标识
   * @param {number} days - 查询天数
   * @returns {Promise}
   */
  getCheckInRecords: function(elderlyId, days = 7) {
    return new Promise((resolve, reject) => {
      // 模拟API调用
      setTimeout(() => {
        resolve({
          success: true,
          data: {
            records: [
              {
                checkInId: 'check_001',
                elderlyId: elderlyId,
                checkInTime: '2025-01-27T08:00:00Z',
                status: 'success'
              }
            ]
          }
        });
      }, 500);
    });
  },

  /**
   * 查询三方协议信息
   * @param {string} userId - 用户ID
   * @returns {Promise}
   */
  getAgreementInfo: function(userId) {
    return new Promise((resolve, reject) => {
      // 模拟API调用
      setTimeout(() => {
        resolve({
          success: true,
          data: {
            agreementInfo: {
              agreementId: 'agreement_001',
              userId: userId,
              status: 'active',
              signDate: '2025-01-01',
              expireDate: '2026-01-01',
              agreementType: 'safety_care'
            }
          }
        });
      }, 500);
    });
  }
};

module.exports = SafetyCareAPI;